/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package serveur;

import Converters.NettyConverter;
import java.net.InetSocketAddress;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.socket.ClientSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

/**
 *
 * @author MOI
 */
public class ServeurBootstrap {

    static public ServerBootstrap creerServeur(int port,NettyConverter proxy)
    {

        

        System.out.println(
                "Create server *:" + port + " to " + proxy + " ...");

        // Configure the bootstrap.
        Executor executor = Executors.newCachedThreadPool();
        ServerBootstrap sb = new ServerBootstrap(
                new NioServerSocketChannelFactory(executor, executor));

        // Set up the event pipeline factory.
        ClientSocketChannelFactory cf =
                new NioClientSocketChannelFactory(executor, executor);

        sb.setPipelineFactory(
                new ServeurPipelineFactory(proxy));

        // Start up the server.
        sb.bind(new InetSocketAddress(port));
        return sb;
    }
}
